package xixirupan.tmgp.tencent.com.vmeim.ui.shopcar.model;

import android.util.Log;

import java.util.List;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import xixirupan.tmgp.tencent.com.vmeim.config.URLConfig;
import xixirupan.tmgp.tencent.com.vmeim.retrofit.IShopCarR;

/**
 * Created by lenovo on 2016/10/20.
 */

public class ShopCarBiz {

 private IShopCarData shopCarData;
    public void getShopcarData(final IShopCarData shopCarData)

    {
        this.shopCarData =shopCarData;

        Retrofit retrofit =new Retrofit.Builder()
                .baseUrl(URLConfig.Url.BASE_URL)
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        IShopCarR iShopCarR = retrofit.create(IShopCarR.class);
        Call<ShopCarRecoBean> call = iShopCarR.shopCarData();
        call.enqueue(new Callback<ShopCarRecoBean>() {
            @Override
            public void onResponse(Call<ShopCarRecoBean> call, Response<ShopCarRecoBean> response) {
                ShopCarRecoBean body = response.body();
                DataBaen data = body.getData();
                List<RecommendProductsBaen> recommendProducts = data.getRecommendProducts();
                Log.i("shopcar的推荐数据","---------------解析成功>"+recommendProducts.size());

                shopCarData.postShopCarData(recommendProducts);
            }

            @Override
            public void onFailure(Call<ShopCarRecoBean> call, Throwable t) {
                Log.i("shopcar下面的推荐数据","---------------解析失败>"+t.getMessage());
            }
        });
    }

}
